﻿///////////////////////////////////////////////////////////////////////////////////////////////
// System.Text.Parsing - © 2011 Sebastien Pellizzari
// Released under the MIT License (http://www.opensource.org/licenses/mit-license.php)
///////////////////////////////////////////////////////////////////////////////////////////////

namespace System.Text.Parsing
{
    /// <summary>Represents a generic representation of a parser grammar.</summary>
    public sealed class GrammarParser
    {
        private readonly GrammarTextValue _name;                    // The name of the parser.
        private readonly GrammarTextValue _tokenizer;               // The name of the tokenizer to use.
        private readonly GrammarTextValue _implementation;          // The name of the parser implementation to use.
        private readonly GrammarPropertyCollection _properties;     // The properties.
        private readonly GrammarCodeBlockCollection _codeBlocks;    // The code blocks.

        //-----------------------------------------------------------------------
        //     Properties
        //-----------------------------------------------------------------------

        /// <summary>Gets the name of the parser.</summary>
        public GrammarTextValue Name { get { return _name; } }
        /// <summary>Gets the name of the tokenizer to use.</summary>
        public GrammarTextValue Tokenizer { get { return _tokenizer; } }
        /// <summary>Gets the name of the parser implementation to use.</summary>
        public GrammarTextValue Implementation { get { return _implementation; } }
        /// <summary>Gets the collection of properties.</summary>
        public GrammarPropertyCollection Properties { get { return _properties; } }
        /// <summary>Gets the collection of code blocks.</summary>
        public GrammarCodeBlockCollection CodeBlocks { get { return _codeBlocks; } }

        //-----------------------------------------------------------------------
        //     Constructors
        //-----------------------------------------------------------------------

        /// <summary>Initializes an instance of the <see cref="GrammarParser"/> class.</summary>
        /// <param name="name">The class name for the parser.</param>
        /// <param name="tokenizer">A string determining the tokenizer to use.</param>
        /// <param name="implementation">A string determining the parser implementation to use.</param>
        public GrammarParser(GrammarTextValue name, GrammarTextValue tokenizer, GrammarTextValue implementation)
        {
            if (name.Text == null) throw new ArgumentNullException("name.Text");
            if (tokenizer.Text == null) throw new ArgumentNullException("tokenizer.Text");
            if (implementation.Text == null) throw new ArgumentNullException("implementation.Text");
            _name = name;
            _tokenizer = tokenizer;
            _implementation = implementation;
            _properties = new GrammarPropertyCollection();
            _codeBlocks = new GrammarCodeBlockCollection();
        }
    }
}
